
/* 公用的js文件 */

/* 引入公共代码片段 */
$(function(){
	sessionStorage.setItem("group_address", "江西省南昌市高新区火炬大街579号");
	
	/* headerHtml(); */
	footerHtml();
	
	/* footer导航 */
	$("#footer_menu").on("click", "a", function(){
		var type = $(this).attr("id")
		window.location.href = type + ".html";
	});
	
});

function exitLogin(){
	sessionStorage.clear();
	localStorage.clear();
	window.location.href = "../../login.htm"
}

/* footer代码片段 */
function footerHtml(){
	var html = "";
	html += '<div class="weui-tabbar tab-bottom" style="background: #fff;">'
	html +=     '<a id="shop_index" href="javascript:;" class="weui-tabbar__item">'
	html +=         '<span style="display: inline-block;position: relative;">'
	html +=             '<i class="icon icon-27 f27 weui-tabbar__icon"></i>'
	html +=         '</span>'
	html +=         '<p class="weui-tabbar__label">首页</p>'
	html +=		'</a>'
	html +=     '<a id="shop_order" href="javascript:;" class="weui-tabbar__item">'
	html +=			'<i class="icon icon-43 f27 weui-tabbar__icon"></i>'
	html +=			'<p class="weui-tabbar__label">订单</p>'
	html +=		'</a>'
	 
	html +=		'<a id="shop_center" href="javascript:;" class="weui-tabbar__item">'
	html +=			'<i class="icon icon-84 f27 weui-tabbar__icon"></i>'
	html +=			'<p class="weui-tabbar__label">我的</p>'
	html +=		'</a>'
	html += '</div>'
	$("#footer_menu").html(html);
	
	/* 改变选择导航的元素 */
	var ts_href = window.location.href;
	var ts_mainText="";
	var ts_indexof = ts_href.lastIndexOf("/");
	var ts_indexText = ts_href.substring(ts_indexof + 1);
	var ts_htmlBeforeText = ts_indexText.indexOf(".html");
	ts_mainText = ts_indexText.substring(0, ts_htmlBeforeText);
	console.log(ts_mainText);
	$("#" + ts_mainText).addClass('weui-bar__item_on');
};

/* 获取url上的参数 */
function GetRequest() {
	var url = location.search; //获取url中"?"符后的字串
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for (var i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
		}
	}
	return theRequest;
}

// var cflz_service_url = "/cflz_wx/service/app_data_action.ashx";
var cflz_service_url = "http://zz.nxk520.com/netcflz_wx/service/app_data_action.ashx";
var appUrl = "https://ge.nxk520.com/";
var jsonUser, jsonDoc, jsonShop;
//用户编码,用户类型,问诊类型,医生编码
var user_id, user_type, hospital_id, log_type, doctor_id;
//用户姓名,医生姓名
var userName, doctorName;

//医生端tabbar跳转
function tabbargo(){
    $('.weui-tabbar__item').on('click', function () {
   $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
   var type = $(this).attr("id");
   if (type === "inquiry_index") {
       location.href = "inquiry_doctor_index.htm";
   } else if(type === "inquiry_doctor"){
       location.href = "inquiry_doctor.htm";
   }else{
       location.href = "inquiry_user_personal.htm";
   }
});
}
// 图片路径处理
function getUserImgPub(user_img, srcimg) {
    if (isUndefinedAndEmpty(user_img)) {
        if (isUndefinedAndEmpty(srcimg)) {
            user_img = '/static/images/head.png';
        } else {
            user_img = srcimg;
        }

    } else if (user_img.indexOf('http') == -1) { //微信头像
        user_img = appUrl + user_img;
    }
    return user_img;
}

function strToJson(jsonStr) {
    return eval('(' + jsonStr + ')');
}

function jsonToStr(jsonObj) {
    return JSON.stringify(jsonObj);
}

/*将用户数据存储到LocalStorage中*/
function setUserInfo(userJson) {
    var user_type = userJson.type;
    localStorage.setItem("user_type", user_type); //用户类型
    if (user_type == 'P') {
        sessionStorage.setItem("user_id",userJson.id); //用户编码
        localStorage.setItem("user_name", userJson.mobile); //登录账号
    }
    else if (user_type == 'S') {
        sessionStorage.setItem("user_id",  userJson.id); //用户编码
        localStorage.setItem("user_name", userJson.mobile); //登录账号
    }
    sessionStorage.setItem("DSXBuserJson", jsonToStr(userJson));
}

/*从cookie中得到一条userjson 数据*/
function getUserInfo() {
    var userJson = sessionStorage.getItem('DSXBuserJson');
    if (isUndefinedAndEmpty(userJson)) {
        return {};
    }
    return strToJson(userJson);
}

function getUserId() {
    return sessionStorage.getItem('user_id');
}

/*存入缓存 用户 //存入缓存 医生 登录类型 0 用户 1医生*/
function setUserType(index) {
    sessionStorage.setItem("user_doctor_type", index);
}

/*获取用户登录类型缓存 登录类型 0 用户 1医生*/
function getUserType() {
    var num = sessionStorage.getItem("user_doctor_type");
    return num;
}

function isUndefinedAndEmpty(obj) {
    obj = $.trim(obj);
    if (undefined == obj || "undefined" == obj || "" == obj || null == obj) {
        return true;
    }
    return false;
}

/*判断当前用户是否已经登录*/
function isLogin() {
    strUserId = getUserId();
    user_type = localStorage.getItem("user_type");
    bResult = !isUndefinedAndEmpty(strUserId);
    if (bResult)
        user_id = parseInt(strUserId);
    return bResult;
}

function checkLogin() {
    if (!isLogin()) {
        goPage('login.htm');
    }
}

/*获取当前日期*/
function getCurrDate() {
    var myDate = new Date;
    var year = myDate.getFullYear(); //年
    var month = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : (myDate.getMonth() + 1); //月
    var day = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();//日
    return year + '-' + month + '-' + day;
}

//请求数据,strMsgTag数据名称，pJson，callBack
function GetPageData(strMsgTag, pJson, callBack) {
    $.showLoading();
    var dataJson = { "rand": Math.random() };
    if (!isSpace(pJson)) {
        for (var key in pJson) {
            dataJson[key] = pJson[key];
        }
    }
    var ajaxArgs = { url: cflz_service_url,
        data: dataJson,
        succCallback: callBack,
        type:"post",
        errorCallback: function (errorMsg) {
            msgInfo("程序错误，" + errorMsg);
        }
    };
    $ajax(ajaxArgs);
}

function ajaxPost(url, pJson, callBack) {
    ajaxDo('post', 'json', url, pJson, callBack);
}

function ajaxPostH(url, pJson, callBack) {
    ajaxDo('post', 'html', url, pJson, callBack);
}

function ajaxGet(url, pJson, callBack) {
    ajaxDo('get', 'json', url, pJson, callBack);
}

function ajaxGetH(url, pJson, callBack) {
    ajaxDo('get', 'html', url, pJson, callBack);
}

function ajaxDo(doType, dataType, url, pJson, callBack) {
    var dataJson = { "rand": Math.random() };
    if (!isSpace(pJson)) {
        for (var key in pJson) {
            dataJson[key] = pJson[key];
        }
    }
    var strAjaxUrl, ajaxJson;
    if ((url.charAt(0) == '/' && url.indexOf('.ashx') > -1) || url.indexOf('http:') > -1) {
        strAjaxUrl = url;
        ajaxJson = dataJson;
    }
    else {
        strAjaxUrl = appUrl + url + '.do';
        ajaxJson = { "mapStr": jsonToStr(dataJson) };
    }
    var ajaxArgs = { url: strAjaxUrl,
        data: ajaxJson,
        succCallback: callBack,
        dataType: dataType || "json",
        type: doType || "post",
        errorCallback: function (errorMsg) {
            msgInfo("系统异常，错误为" + errorMsg);
        }
    };
    $ajax(ajaxArgs);
}

//ajax函数二次封装
function $ajax(ajaxArgs) {
    var bAsync = ajaxArgs.async || false; //异步请求
    var strDataType = ajaxArgs.dataType || 'json'; //接收数据类型
    var strType = ajaxArgs.type || 'get'; //请求类型
    var bLoad = ajaxArgs.isLoad || false; //是否显示loading动画
    var bLoadParent = ajaxArgs.isParent || false; //显示父页loading动画
    var strLoadText = ajaxArgs.loadText || ''; //显示内容
    var succCallback = ajaxArgs.succCallback; //成功回调函数
    var errorCallback = ajaxArgs.errorCallback; //失败回调函数    
    $.ajax({
        async: bAsync,
        url: ajaxArgs.url,
        data: ajaxArgs.data,
        dataType: strDataType,
        type: strType,
        beforeSend: function () {//开始loading
            if (bLoad) { }
        },
        success: function (rstData) {
            $.hideLoading();
            if ($.isFunction(succCallback))
                succCallback(rstData);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $.hideLoading();
            if ($.isFunction(errorCallback))
                errorCallback(textStatus + "\r\n" + errorThrown);
        },
        complete: function () {//结束loading
            if (bLoad) { }
        }
    });
}

//判断字符串为空
function isSpace(strMain) {
    var strComp = strMain;
    try {
        if (strComp == "　" || strComp == "" || strComp == " " || strComp == null || strComp == "null" || strComp == "0" || strComp.length == 0 || typeof strMain == "undefined" || strMain == "undefined") {
            return true;
        }
        else {
            return false;
        }
    }
    catch (e) {
        return false;
    }
}

//后退或前进
function goPageNo(count) {
    history.go(count);
}

//页面跳转
function goPage(url) {
    location.href = url;
}

//获取URL参数
function getQst(name) {
    var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1) {
        return "";
    }
    return decodeURI(result[1]);
}

//过滤HTML标签
function filterHTMLTag(str) {
    var msg = str.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
    msg = msg.replace(/[|]*\n/, ''); //去除行尾空格
    msg = msg.replace(/&nbsp;/ig, ''); //去掉npsp
    return msg;
}

//弹窗
function msgInfo(msg) {
    if (msg == "") msg = "建设中……";
    $.toast.prototype.defaults.duration = 1000; //1秒
    $.toast(msg, 'text');
}
/**
 * 生成二维码
 * @param {any} obj
 * @param {any} width
 * @param {any} height
 */
function getQCCode(ID, obj, width, height) {
    var qrcode = new QRCode(document.getElementById(ID), {
        width: width,
        height: height
    });
    var elText = obj;
    if (!elText.value) {
        elText.focus();
        return;
    }
    qrcode.makeCode(elText.value);
}



//判断用户绑定
function checkUSBD(thisURL) {
    if (isSpace(localStorage.getItem("jsonUser")) || localStorage.getItem("jsonUser") == "null") {
        location.href = "login.htm?thisurl=" + thisURL;
    }
    else {
        jsonUser = JSON.parse(localStorage.getItem("jsonUser"));
        var pJson = { "actName": "Patient", "actTag": "pLogin", "strTel": jsonUser.username, "strPassword": jsonUser.password };
        GetPageData("判断用户绑定", pJson, function (rstData) {
            if (rstData.total == "0") {
                localStorage.setItem('jsonUser', null);
                $.alert("登录已过期或无效", "标题", function () {
                    location.href = "login.htm?thisurl=" + thisURL;
                });
            } else {
                jsonUser = rstData.rows[0];
                localStorage.setItem('jsonUser', JSON.stringify(rstData.rows[0]));
            }

        });
    }
}

//判断医生绑定
function checkUSBD_doc(thisURL) {
    cflz_service_url = "/cflz_wx/service/app_data_action_doc.ashx";
    if (isSpace(localStorage.getItem("jsonDoc")) || localStorage.getItem("jsonDoc") == "null") {
        location.href = "doc_login.htm?thisurl=" + thisURL;
    }
    else {
        jsonDoc = JSON.parse(localStorage.getItem("jsonDoc"));
        var docJson = { "actName": "Doctor", "actTag": "dLogin", "user_name": jsonDoc.user_name, "pass_word": jsonDoc.pass_word };
        GetPageData("判断医生绑定", docJson, function (rstData) {
            if (rstData.total != "1") {
                localStorage.setItem('jsonDoc', null);
                $.alert("登录已过期或无效", "标题", function () {
                    location.href = "doc_login.htm?thisurl=" + thisURL;
                });
            } else {
                if (rstData.rows[0].msg != "登录成功") {
                    localStorage.setItem('jsonDoc', null);
                    $.alert("登录已过期或无效", "标题", function () {
                        location.href = "doc_login.htm?thisurl=" + thisURL;
                    });
                }
                else {
                    jsonDoc = rstData.rows[0];
                    localStorage.setItem('jsonDoc', JSON.stringify(rstData.rows[0]));
                }
            }
        });
    }
}

//判断药店绑定
function checkUSBD_shop(thisURL) {
    cflz_service_url = "/cflz_wx/service/app_data_action_shop.ashx";
    if (isSpace(localStorage.getItem("jsonShop")) || localStorage.getItem("jsonShop") == "null") {
        location.href = "shop_login.htm?thisurl=" + thisURL;
    }
    else {
        jsonShop = JSON.parse(localStorage.getItem("jsonShop"));
        var shopJson = { "actName": "Shop", "actTag": "sLogin", "user_name": jsonShop.user_name, "pass_word": jsonShop.pass_word };
        GetPageData("判断药店绑定", shopJson, function (rstData) {
            if (rstData.total != "1") {
                localStorage.setItem('jsonShop', null);
                $.alert("登录已过期或无效", "标题", function () {
                    location.href = "shop_login.htm?thisurl=" + thisURL;
                });
            } else {
                if (rstData.rows[0].msg != "登录成功") {
                    localStorage.setItem('jsonShop', null);
                    $.alert("登录已过期或无效", "标题", function () {
                        location.href = "shop_login.htm?thisurl=" + thisURL;
                    });
                }
                else {
                    jsonShop = rstData.rows[0];
                    localStorage.setItem('jsonShop', JSON.stringify(rstData.rows[0]));
                }
            }
        });
    }
}

function IsPhone(phones) {
    var myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
    return (myreg.test(phones));
}


///验证身份证
function IsIdCard(idcard) {
    //var Errors = new Array("验证通过!", "身份证号码位数不对!", "身份证号码出生日期超出范围或含有非法字符!", "身份证号码校验错误!", "身份证地区非法!");
    var area = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁",
        22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建",
        36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西",
        46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西",
        62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门",
        91: "国外"
    }
    idcard = idcard.toUpperCase();
    var Y, JYM; var S, M; var idcard_array = new Array(); idcard_array = idcard.split("");
    //地区检验
    if (area[parseInt(idcard.substr(0, 2))] == null) {
        return false;
    }
    //身份号码位数及格式检验
    switch (idcard.length) {
        case 15: if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0))
                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/; //测试出生日期的合法性
            else ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/; //测试出生日期的合法性
            if (ereg.test(idcard)) break;
            else { return false; } break;
        case 18:
            //18位身份号码检测
            //出生日期的合法性检查 
            //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
            //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
            if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0))
                ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/; //闰年出生日期的合法性正则表达式
            else ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/; //平年出生日期的合法性正则表达式
            if (ereg.test(idcard)) {//测试出生日期的合法性
                //计算校验位
                S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
                (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 +
                (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 +
                (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 +
                (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 +
                (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 +
                (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 +
                parseInt(idcard_array[7]) * 1 + parseInt(idcard_array[8]) * 6 +
                parseInt(idcard_array[9]) * 3;
                Y = S % 11; M = "F"; JYM = "10X98765432"; M = JYM.substr(Y, 1); //判断校验位
                if (M == idcard_array[17]) break; //检测ID的校验位
                else { return false; }
            } else { return false; } break;
        default: return false; break;
    }
    return true;
}


//判断一个变量是否是日期型
function isDate(sDate) {
    var arrDate = sDate.split("-");
    if (arrDate.length != 3) return false;

    var year = arrDate[0];
    var month = arrDate[1];
    var day = arrDate[2];

    if (isEmpty(year) || isEmpty(month) || isEmpty(day)) return false;
    if (isNaN(year) || isNaN(month) || isNaN(day)) return false;

    year = parseInt(LTrimZero(year));
    month = parseInt(LTrimZero(month));
    day = parseInt(LTrimZero(day));

    if (year < 0 || month > 12 || day > 31 || month <= 0 || day <= 0) return false;

    switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            return true;
        case 4:
        case 6:
        case 9:
        case 11:
            if (day > 30) return false;
            return true;
        case 2:

            //闰年
            if (0 == year % 4 && (year % 100) != 0 || 0 == year % 400) {
                if (day > 29) return false;
                return true;
            }
            //非闰年 
            if (day > 28) return false;
            return true;
        default:
            return false;
    }
}


//判断一个字符串是否为空字符串
function isEmpty(s) {
    return "" == Trim(s);
}



/*=============== 数据处理函数 ===========*/
function LTrim(s) {
    for (var i = 0; i < s.length; i++) {
        if (s.charAt(i) != " ") {
            return s.substr(i, s.length - i);
        }
    }
    return "";
}

function RTrim(s) {
    for (var i = s.length - 1; i >= 0; i--) {
        if (s.charAt(i) != " ") {
            return s.substr(0, i + 1);
        }
    }
    return "";
}

function Trim(s) {
    if (typeof s == "undefined" || s == "undefined")
        s = "";
    else
        s = RTrim(LTrim(s));
    return s;
}


function LTrimZero(s) {
    for (var i = 0; i < s.length; i++) {
        if (s.charAt(i) != "0") {
            return s.substr(i, s.length - i);
        }
    }
    return "";
}

//验证证件号 并把生日, 性别赋值
function checkidno(idno, objbirth, objsex) {
    var nian, yue, ri, csrq, xingbie, s;
    var sex_code, birthdate;
    var s = idno.value;
    if (!IsIdCard(s)) {
        msgInfo("请输入正确的身份证号码！");
        return false;
    }
    //身份证为15位
    if (s.length == 15) {
        nian = s.substr(6, 2);
        yue = s.substr(8, 2);
        ri = s.substr(10, 2);
        csrq = "19" + nian + "-" + yue + "-" + ri;
        xingbie = s.charAt(14);
        if (xingbie % 2 == 0) {
            sex_code = "1";
        }
        else {
            sex_code = "0";
        }
        setCtlVal(objsex, sex_code);
        if (isDate(csrq)) {
            birthdate = csrq;
            setCtlVal(objbirth, csrq);
        }
        else {
            msgInfo("请输入正确的身份证号码！");
            return false;
        }
    }
    //身份证为18位
    else if (s.length == 18) {
        nian = s.substr(6, 4);
        yue = s.substr(10, 2);
        ri = s.substr(12, 2);
        csrq = nian + "-" + yue + "-" + ri;
        xingbie = s.charAt(16);
        if (xingbie % 2 == 0) {
            sex_code = "1";
        }
        else {
            sex_code = "0";
        }
        setCtlVal(objsex, sex_code);
        if (isDate(csrq)) {
            birthdate = csrq;
            setCtlVal(objbirth, csrq);
        }
        else {
            msgInfo("请输入正确的身份证号码！");
            return false;
        }
    }
    else {
        msgInfo("身份证号必需要15位或18位！");
        return false;
    }
    return true;
}

function setCtlVal(ctlId, ctlVal) {
    if (ctlId != null)
        ctlId.value = ctlVal;
}

function BindSelectData(ctrlId, tbName) {
    var str_item = "";
    GetPageData('获取字典', { "actName": "Doctor", "actTag": "D999", "tbName": tbName }, function (rstData) {
        $("#text_" + ctrlId).select({
            title: "",
            items: rstData,
            onChange: function (d) {
                $("#hid_" + ctrlId).val($("#text_" + ctrlId).attr("data-values"));
                console.log(this, d);
            },
            onClose: function () {
                console.log("close");
            },
            onOpen: function () {
                console.log("open");
            }
        });
    });
}

function SetFormCtls(rstData) {
    var str_name, str_key;
    $("input").each(function () {
        str_name = $(this).attr('id');
        if (!isSpace(str_name) && ((str_name.indexOf("hid_") == 0) || (str_name.indexOf("txt_") == 0) || (str_name.indexOf("ckb_") == 0))) {
            str_key = str_name.substring(4);
            if (str_key in rstData)
                $('#' + str_name).attr('value', rstData[str_key]);
        }
        if (!isSpace(str_name) && (str_name.indexOf("ckb_") == 0)) {
            str_key = str_name.substring(4);
            if (str_key in rstData && rstData[str_key] == '1')
                $('#' + str_name).attr('checked', true);
        }
    });
    $("select").each(function () {
        str_name = $(this).attr('id');
        if (!isSpace(str_name) && str_name.indexOf("ddl_") == 0) {
            str_key = str_name.substring(4);
            if (str_key in rstData)
                $('#' + str_name).attr('value', rstData[str_key]);
        }
    });
    $("textarea").each(function () {
        str_name = $(this).attr('id');
        if (!isSpace(str_name) && str_name.indexOf("txt_") == 0) {
            str_key = str_name.substring(4);
            if (str_key in rstData)
                $('#' + str_name).html(rstData[str_key]);
        }
    });
}

//ctrlId点击此控件弹出全屏, pid为a标签id
function OpenPopup(ctrlId,pid) {
    $("#" + ctrlId).focus(function () {
        $("#a_show"+pid).click();
    });
}
//ctrlId显示中文的控件, ctrlHidId记录code的隐藏域, pid为a标签id
function ClosePopup(ctrlId, ctrlHidId, pid, icd_code, icd_name) {
    $("#" + ctrlHidId).val(icd_code);
    $("#" + ctrlId).val(icd_name);
    $("#a_close" + pid).click();
}
//ctrlId显示中文的控件, ctrlHidId记录code的隐藏域, pid为a标签id,divId
function LoadPopupData(pJson, ctrlId, ctrlHidId, pid, divId) {
    var dataJson = { "actName": "Doctor", "actTag": "Get_ICD" };
    if (!isSpace(pJson)) {
        for (var key in pJson) {
            dataJson[key] = pJson[key];
        }
    }
    GetPageData('', dataJson, function (rstData) {
        if (rstData.total > 0) {
            var str_cells = "";
            for (var i = 0; i < rstData.total; i++) {
                str_cells += "<div class=\"weui-cells\">";
                str_cells += "<a class=\"weui-cell weui-cell_access\" href=\"javascript:ClosePopup('" + ctrlId + "','" + ctrlHidId + "','" + pid + "','" + rstData.rows[i].value + "','" + rstData.rows[i].content + "')\">";
                str_cells += "<div class=\"weui-cell__bd\">";
                str_cells += "<p>" + rstData.rows[i].content + "</p>";
                str_cells += "</div>";
                str_cells += "<div class=\"weui-cell__ft\">";
                str_cells += "</div>";
                str_cells += "</a>";
                str_cells += "</div>";
            }
            $("#" + divId).html(str_cells);
        }
        else { $("#" + divId).html("无查询结果"); }
    });
}

//后退或前进
function actPageGo(count) {
    history.go(count);
}
//页面跳转s
function actToPage(url) {
    location.href = url;
	window.location.href=document.referrer;
}



